<template>
	<view class="examinationReserve"><SwitchPatient :id="Data.optionid" :fun="changeuser"></SwitchPatient></view>
	<view class="uni-padding-wrap uni-common-mt">
		<uni-segmented-control :current="Data.current" :values="Data.items" style-type="button" active-color="#007aff" @clickItem="onClickItem" />
	</view>
	<view class="content">
		<view v-for="(v, i) in Data.items" :key="v">
			<view v-if="Data.current === i">
				<uni-card
					v-for="v2 in Data.items2"
					:key="v2.id"
					:title="v2.name"
					:sub-title="v2.context"
					:extra="v2.price"
					thumbnail="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png"
					@click="go(v2.id)"
				></uni-card>
			</view>
		</view>
	</view>
</template>

<script setup>
import SwitchPatient from '@/components/SwitchPatient.vue';
import { packageType, packageQuery } from '@/api/ExaminationService.js';
import { reactive, onMounted, defineComponent, ref } from 'vue';
import { medicalStore,examinationDataStore } from '@/store/medicalStore.js';
import { onLoad } from '@dcloudio/uni-app';
const store = medicalStore();
const DataStore =examinationDataStore();
let p1 = packageType({
	name: ''
});
let Data = reactive({
	items: [],
	items2: [],
	current: 0,
	list: {},
	id: [],
	name:[],
	netxid:0
});
let onClickItem = e => {
	console.log(e.currentIndex);
	if (Data.current !== e.currentIndex) {
		Data.current = e.currentIndex;
	}
	packageQuery({ id: Data.id[e.currentIndex] })
		.then(({ data }) => {
			Data.items2 = data.data;
			console.log("9999",data.data);
		})
		.catch(err => {
			console.log(err);
		});
};
const changeuser=(v)=>{
	Data.netxid=v.id
}
const packageTy = () => {
	p1.then(({ data }) => {
		let arr = data.data.map(v => v.name);
		let arr2 = data.data.map(v => v.id);
		Data.items = arr;
		Data.id = arr2;
	}).catch(err => {
		console.log(err);
	});
};
let go = id => {
		console.log(id)
	DataStore.set(v => {
		v.package = Data.items2;
		v.packageid = id;
	});
	store.id = id;
	// console.log(store.id)
	uni.navigateTo({
		url: `/pages/examinationService/packageDetail/packageDetail?id=${Data.netxid}&pageid=${id}`
	});
};
// const goto = id => {
// 	uni.navigateTo({
// 		url: `/pages/examinationService/packageDetail/packageDetail?id=${id}`
// 	});
// 	console.log('用户id', id);
// };
onMounted(() => {
	// console.log(Data.items2)
	//查询套餐类型
	packageTy();
	//查询套餐
	packageQuery({ id: 1 })
		.then(({ data }) => {
			// let arr = data.data.map(v => v);
			// data.data.forEach(v => {
			// 	Data.list = v;
			// });
			Data.items2 = data.data;
			console.log(data.data);
		})
		.catch(err => {
			console.log(err);
		});
});
onLoad(option => {
	Data.optionid = option.id;
	console.log(option.id);
});
</script>

<style scoped lang="less">
.examinationReserve {
}
.example-body {
	/* #ifndef APP-NVUE */
	display: flex;
	/* #endif */
	flex-direction: row;
	padding: 0;
}

.uni-common-mt {
	margin-top: 32rpx;
}

.uni-padding-wrap {
	// width: 750rpx;
	padding: 0px 36rpx;
}
/deep/.segmented-control.data-v-064e9cd1 {
	height: 24px;
}
/deep/.segmented-control__text.data-v-064e9cd1 {
	font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
	font-weight: 400;
	font-style: normal;
	font-size: 12px;
	line-height: 24px;
	color: #333333;
}
.content .data-v-666265bd {
	margin-top: 90rpx;
	width: 740rpx;
}

/deep/.uni-card .uni-card__header {
	border: none;
}
/deep/.uni-card .uni-card__header .uni-card__header-avatar {
	width: 60px;
	height: 68px;
}
/deep/.uni-card .uni-card__header .uni-card__header-content {
	width: 100px;
	overflow: visible;
}
/deep/.uni-card .uni-card__header .uni-card__header-box {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-around;
}
/deep/.uni-card__header-content {
}
/deep/.uni-card .uni-card__header .uni-card__header-content .uni-card__header-content-subtitle {
	width: 140px;
	visibility: visible;
	white-space: normal;
}

/deep/.uni-card .uni-card__header .uni-card__header-extra .uni-card__header-extra-text {
	font-family: 'PingFangSC-Medium', 'PingFang SC Medium', 'PingFang SC', sans-serif;
	font-weight: 500;
	font-style: normal;
	font-size: 17px;
	color: #f46363;
}
/deep/.uni-card .uni-card__content {
	padding: 0px !important ;
}

.content-text {
	font-size: 14px;
	color: #666;
}

// .uni-list {
// 	flex: 1;
// }

.uni-list-item {
	/* #ifndef APP-NVUE */
	display: flex;
	/* #endif */
	// flex: 1;
	flex-direction: row;
	background-color: #ffffff;
}

.uni-list-item__container {
	padding: 12px 15px;
	width: 100%;
	// flex: 1;
	position: relative;
	/* #ifndef APP-NVUE */
	display: flex;
	box-sizing: border-box;
	/* #endif */
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	border-bottom-style: solid;
	border-bottom-width: 1px;
	border-bottom-color: #eee;
}

.uni-list-item__content-title {
	font-size: 14px;
}
.box {
	margin-top: ;
}
</style>
